#include "panel.h"
#include "masterpanel.h"

int Panel::getDirtyRectangleCount()
{
	return getMasterPanel()->getDirtyRectangles()->size();
}
SRect * Panel::getDirtyRectangle(const int & a_index)
{
	return &getMasterPanel()->getDirtyRectangles()->get(a_index);
}
void Panel::addDirtyRectangle(const SRect & a_dirtyArea)
{
	bool merged = false;
	TemplateVector<SRect> * dr = getMasterPanel()->getDirtyRectangles();
	for(int i = 0; !merged && i < dr->size(); ++i)
	{
		if(dr->get(i).intersects(a_dirtyArea))
		{
			dr->get(i).add(a_dirtyArea);
			merged = true;
		}
	}
	if(!merged)
		dr->add(a_dirtyArea);
}
